<template>
	<view>
		<!-- <u-swiper :list="info.lbs" radius="0" height="300"></u-swiper> -->
		<view class="detail">
			<view class="head">
				<view class="title">{{info.title}}</view>
				<view class="share">
					<view class="item" @click="doLike()">
						<u-icon label="收藏" size="24" labelSize="14" :name="info.has_like ? 'star-fill' : 'star'" labelPos="bottom"></u-icon>
					</view>
					<u-button class="item" open-type="share"  @click="doShare()">
						<u-icon label="分享" size="24" labelSize="14" name="share" labelPos="bottom"></u-icon>
					</u-button>
				</view>
			</view>
			
			<view>
				{{info.content}}
			</view>
			<view v-if="info.lbs">
				<u-album
					:urls="info.lbs"
				></u-album>
			</view>
			
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				myinfo: {},
				id:'',
				info:{},
			};
		},
		onLoad(e) {
			if(!uni.getStorageSync('LOGIN_TOKEN_KEY')){
				uni.navigateTo({
					url: "/pages/login/login"
				});
				return;
			}
			if(e&&e.id){
				this.id = e.id;
				this.getDetailFun();
				this.getUserInfo();
			}else{
				uni.navigateBack()
			}
			
			
		},
		methods:{
			doLike(){
				var _this = this;
				uni.$u.http.post("/Opern/likeOrDislike",{id: this.id}).then(async res =>{
					_this.getDetailFun();
				}).catch(err => {
				})
			},
			getUserInfo(){
					 uni.$u.http.get('/User/center',{}).then(async res =>{
					 	this.myinfo = res
					 }).catch(err => {
					 })
			},
			getDetailFun(){
				var _this = this;
				uni.$u.http.get('/Opern/detail?id='+ this.id).then(async res =>{
					_this.info = res;
					uni.$u.mpShare = {
						title: _this.info.title || '', // 默认为小程序名称，可自定义
						path: '/pages/info/detail?id=' + _this.id, // 默认为当前页面路径，一般无需修改，QQ小程序不支持
						// 分享图标，路径可以是本地文件路径、代码包文件路径或者网络图片路径。
						// 支持PNG及JPG，默认为当前页面的截图
						imageUrl:  _this.info.lbs[0] || '' 
					}
				}).catch(err => {
				})
			},
		
		}
	}
</script>

<style lang="scss" scoped>
	.title{
		flex: 1;
		font-weight: 600;
	}
	.share{
		display: flex;
		margin-left: 20rpx;
		.item{
			margin-left: 20rpx;
		}
	}
	.price-box{
		display: flex;
		justify-content: space-between;
		align-items: center;
		background-color: #f5f5f5;
		margin: 0 30rpx 30rpx 30rpx;
		padding: 30rpx;
		border-radius: 12rpx;
		.price-txt{
			font-size: 32rpx;
		}
		.price{
			.price-num{
				font-size: 40rpx;
				font-weight: 600;
				color: red;
			}
			.unit{
				font-size: 24rpx;
				margin-left: 10rpx;
			}
		}
	}
	
</style>
